//
//  ColorManager.m
//  CarService
//
//  Created by Nimo.Yu on 15/1/30.
//  Copyright (c) 2015年 lexingsoft. All rights reserved.
//

#import "ColorManager.h"

@implementation ColorManager

///主色值
+ (UIColor *)colorWithMain
{
    return [self colorWithHexString:@"#FFFFFF"];
}

+ (UIColor *)colorWithNormal
{
    return [self colorWithHexString:@"#f3985b"];
}

+ (UIColor *)colorWithClick
{
    return [self colorWithHexString:@"#cd6929"];
}

+ (UIColor *)colorWithHeader
{
    return [self colorWithHexString:@"#000000" alpha:0.8];
}

+ (UIColor *)colorWithTextSubtitle
{
    return [self colorWithHexString:@"#000000" alpha:0.6];
}

+ (UIColor *)colorWithBorderLines
{
    return [self colorWithHexString:@"c6cbce"];
}

+ (UIColor *)colorWithViewBackground
{
    return [UIColor groupTableViewBackgroundColor];
}

///Cell背景色
+ (UIColor *)colorWithCellBackground
{
    return [UIColor whiteColor];
}

+ (UIColor *)colorWithNavigationBar
{
    return [UIColor blackColor];
}

///导航栏背景色值
+ (UIColor *)colorWithNavigationBarBackground
{
    return [self colorWithMain];;
}

+ (UIColor *)colorWithCommitBackground
{
    return [self colorWithHexString:@"#5cb3f6"];
}

+ (UIColor *) colorWithUnfollow
{
    return [self colorWithHexString:@"9CD6FA"];
}

+ (UIColor *)colorWithHexString:(NSString *)stringToConvert alpha:(CGFloat)alpha
{
    NSString *cString = [[stringToConvert stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
    if ([cString length] < 6)
        return [UIColor whiteColor];
    if ([cString hasPrefix:@"#"])
        cString = [cString substringFromIndex:1];//去掉头
    if ([cString length] != 6)
        return [UIColor whiteColor];
    NSRange range;
    range.location = 0;
    range.length = 2;
    NSString *rString = [cString substringWithRange:range];
    
    range.location = 2;
    NSString *gString = [cString substringWithRange:range];
    
    range.location = 4;
    NSString *bString = [cString substringWithRange:range];
    
    unsigned int r, g, b;
    [[NSScanner scannerWithString:rString] scanHexInt:&r];
    [[NSScanner scannerWithString:gString] scanHexInt:&g];
    [[NSScanner scannerWithString:bString] scanHexInt:&b];
    return [UIColor colorWithRed:((float) r / 255.0f)
                           green:((float) g / 255.0f)
                            blue:((float) b / 255.0f)
                           alpha:alpha];
}

+ (UIColor *)colorWithHexString:(NSString *)stringToConvert
{
    return [self colorWithHexString:stringToConvert alpha:1.0f];
}

@end
